package light.mvc.model.register;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import light.mvc.model.admin.Tuser;
import light.mvc.model.base.IdEntity;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "register")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Tregister extends IdEntity implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	private Integer type;		//挂号方式：0为预约挂号,1为现场挂号
	private Date reserveTime;	//预约挂号时的时间
	private Date registerTime;  //现场挂号的时间
	private Date timeSegment;   //挂号的时间段,8点为上午,14点为下午
	private Integer seq;		//当前时间段的排序号
	
	private Tuser patient;
	private Tuser doctor;
	private Tprescription prescription;

	private Set<TregisterCharge> registerCharges = new HashSet<TregisterCharge>(0);
	
	private Set<TregisterTreatment> RegisterTreatments = new HashSet<TregisterTreatment>(0);

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "patient_id")
	public Tuser getPatient() {
		return patient;
	}
	public void setPatient(Tuser patient) {
		this.patient = patient;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "doctor_id")
	public Tuser getDoctor() {
		return doctor;
	}
	public void setDoctor(Tuser doctor) {
		this.doctor = doctor;
	}
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "prescription_id")
	public Tprescription getPrescription() {
		return prescription;
	}
	public void setPrescription(Tprescription prescription) {
		this.prescription = prescription;
	}
	
	@OneToMany(mappedBy = "register")
	public Set<TregisterTreatment> getRegisterTreatments() {
		return RegisterTreatments;
	}
	public void setRegisterTreatments(Set<TregisterTreatment> registerTreatments) {
		RegisterTreatments = registerTreatments;
	}
	
	@OneToMany(mappedBy = "register")
	public Set<TregisterCharge> getRegisterCharges() {
		return registerCharges;
	}
	public void setRegisterCharges(Set<TregisterCharge> registerCharges) {
		this.registerCharges = registerCharges;
	}

	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	
	public Date getReserveTime() {
		return reserveTime;
	}
	public void setReserveTime(Date reserveTime) {
		this.reserveTime = reserveTime;
	}
	public Date getRegisterTime() {
		return registerTime;
	}
	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}
	public Date getTimeSegment() {
		return timeSegment;
	}
	public void setTimeSegment(Date timeSegment) {
		this.timeSegment = timeSegment;
	}
	public Integer getSeq() {
		return seq;
	}
	public void setSeq(Integer seq) {
		this.seq = seq;
	}

}
